package com.lzq.leetcode.lanqiao;

import java.util.Arrays;
import java.util.Scanner;

public class s1025 {

    private static class Stu implements Comparable{
        int s;
        int a;
        int e;

        public Stu(int s, int a, int e) {
            this.s = s;
            this.a = a;
            this.e = e;
        }

        @Override
        public int compareTo(Object o) {
            Stu oth = (Stu) o;
            return this.s + this.a + this.e - oth.s - oth.a - oth.e;
        }


    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Stu[] stus = new Stu[n];
        for (int i=0; i<n; i++) {
            stus[i] = new Stu(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
        }

        Arrays.sort(stus);

        // 计算时间
        long sum = 0;
        for (int i=0; i<n; i++) {
            sum += (long) (stus[i].s + stus[i].a + stus[i].e) * (n-i) - stus[i].e;
        }

        System.out.println(sum);
    }

}
